package com.zhiyou.controller;

import java.sql.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.common.json.JSON;
import com.zhiyou.model.FYStudyAttendance;
import com.zhiyou.service.TeacherManageService;
import com.zhiyou.utils.JsonResult;

import lombok.experimental.PackagePrivate;

@RestController
@RequestMapping("Manage/")
public class TeacherManageController {
	@Autowired
	TeacherManageService teacherManageService;
	
	//老师页面的考勤上栏
	@GetMapping("hurdleShow/{class_id}/{year}/{month}")
	public JsonResult show(@PathVariable("class_id")Integer class_id,@PathVariable("year") Integer year,@PathVariable("month")Integer month,HttpServletRequest request,HttpServletResponse response){
		System.out.println(class_id+"班级"+year+"年"+month+"月"+"***************************************************************************************************");
		return new JsonResult(teacherManageService.SelectByClassTID(class_id, year, month),"查询成功");
	}
	
	/*这是第一模块*/
	//老师页面的考勤下栏
	@GetMapping("StudentShow/{class_id}/{year}/{month}")
	public JsonResult show11(@PathVariable("class_id")Integer class_id,@PathVariable("year") Integer year,@PathVariable("month")Integer month,HttpServletRequest request,HttpServletResponse response){
		System.out.println("查询结果"+teacherManageService.SelectByStudent(class_id, year, month));	
		return new JsonResult(teacherManageService.SelectByStudent(class_id, year, month),"查询成功");
	}

	//这是查学生考勤状况的
	@GetMapping("DetailsTop/{student_id}/{year}/{month}")
	public JsonResult DetailsTop(@PathVariable("student_id")Integer student_id,@PathVariable("year")Integer year,@PathVariable("month")Integer month){
		System.out.println("我是单个学生的详情页"+teacherManageService.SelectByStudentId(student_id, year, month));
		return new JsonResult(teacherManageService.SelectByStudentId(student_id, year, month),"查询成功");
	}
	@GetMapping("DetailsBottom/{student_id}/{year}/{month}")
	public JsonResult DetailsBottom(@PathVariable("student_id")Integer student_id,@PathVariable("year")Integer year,@PathVariable("month")Integer month){
		System.out.println("我是单个学生的详情页"+teacherManageService.SelectByStudentIdTwo(student_id, year, month));
		return new JsonResult(teacherManageService.SelectByStudentIdTwo(student_id, year, month),"查询成功");
	}
	
	//添加
	@PostMapping("add")
	public JsonResult tianjia(FYStudyAttendance fyStudyAttendance,HttpServletRequest request,HttpServletResponse response){
		teacherManageService.add(fyStudyAttendance);
		return new JsonResult("添加成功");
	}
	
	
	//模糊查询
	@GetMapping("FuzzyQuery/{student_name}")
	public JsonResult FuzzyQuery(@PathVariable("student_name")String student_name,HttpServletRequest request,HttpServletResponse response){
		System.out.println("我是模糊查询"+teacherManageService.selectByStudentName(student_name));
		return new JsonResult(teacherManageService.selectByStudentName(student_name),"查询成功");
	}

	//修改考勤
	@PostMapping("gai")
	public JsonResult xiugai(FYStudyAttendance fyStudyAttendance,HttpServletRequest request,HttpServletResponse response){
		teacherManageService.updateManage(fyStudyAttendance);
		return new JsonResult("修改成功");
	}

	//智慧班牌的考勤查询的数字
	@GetMapping("Banter/{class_id}")
	public JsonResult banpai(@PathVariable("class_id")Integer class_id,HttpServletRequest request,HttpServletResponse response){
		System.out.println("班级id是"+class_id);
		return new JsonResult(teacherManageService.selectCheckSum(class_id),"查询成功");
	
	}
	
	//智慧班牌的考勤查询的展示(如果id=1的话就是查询已出勤的,如果id!=1的话就是查询未出勤的)
	@GetMapping("invincible/{id}/{class_id}")
	public JsonResult zhanshi(@PathVariable("id")Integer id,@PathVariable("class_id")Integer class_id,HttpServletRequest request ,HttpServletResponse response){
		System.out.println("id是:"+id+";班级id是:"+class_id+".");
		return new JsonResult(teacherManageService.SelectUnify(id, class_id),"查询成功");
	}

	@PostMapping("Obscure")
	public JsonResult MHCX(Integer id,Integer class_id,String student_name,HttpServletRequest request ,HttpServletResponse response){
	System.out.println("id是:"+id+";班级id是:"+class_id+";学生模糊查:"+student_name+".");
	return new JsonResult(teacherManageService.SelectMHCX(id, class_id, student_name),"查询成功");
	}
}


